﻿using Ivory;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Ivory.GUI;
using Ivory.Libs;
using X13.Player;

namespace Sweeper
{
    using Globals = X13.Globals;
    using X13;

    public class MainMenu : MainMenuScreen
    {
        //Fields
        private Texture2D _Background;
        private GUI _LoginGUI;

        //Construct
        public MainMenu(Game game)
            : base(game)
        {

        }

        //Methods
        public override void RenderMenu(SpriteBatch batch, GameTime time)
        {
            batch.Begin();

            _LoginGUI.DrawGUI(batch, time);

            batch.End();
        }
        public override void UpdateMenu(GameTime time, InputControl input)
        {
            _LoginGUI.UpdateGUI(input, time);
        }
        
        public override bool LoadAssets()
        {
            _Background = Load<Texture2D>("graphics/menubackground");
            _LoginGUI = new GUI();

            TextButton rt1 = new TextButton(Game, Resources.Fonts["Default"], "RT1", new Vector2(50, 50));
            rt1.LeftClicked += (s, e) => { Manager.SwitchToGameScreen(RenderTest01.Key); };

            TextButton rt2 = new TextButton(Game, Resources.Fonts["Default"], "RT2", new Vector2(50, 100));
            rt2.LeftClicked += (s, e) => { Manager.SwitchToGameScreen(RenderTest02.Key); };
            
            _LoginGUI.AddComponent(rt1);
            _LoginGUI.AddComponent(rt2);

            return true;
        }
    }
}
